const router = require('koa-router')()
const utlis = require('../utlis/common')
const {Menu} = require('../models/menuSchema')
router.prefix('/menus')

router.get('/list',async ctx=>{
  const { menuName,menuState } = ctx.request.query
  const params={}
  if(menuName)params.menuName=menuName
  if(menuState)params.menuState=menuState
  let rootList =await Menu.find(params) || []
  const permissionList = getTreeMenu(rootList,null,[])
  ctx.body=utlis.success(permissionList)
})





module.exports = router